home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / NetSprocket / NewNSpTest Sources / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-18  |  3.6 KB  |  161 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. #
  3. #        main.c
  4. #
  5. #        This is the main entry point.
  6. #
  7. #        Author(s):     Michael Marinkovich
  8. #                    Apple Developer Technical Support
  9. #                    marink@apple.com
  10. #
  11. #        Modification History: 
  12. #
  13. #            2/10/96        MWM     Initial coding                     
  14. #
  15. #        Copyright © 1992-96 Apple Computer, Inc., All Rights Reserved
  16. #
  17. #
  18. #        You may incorporate this sample code into your applications without
  19. #        restriction, though the sample code has been provided "AS IS" and the
  20. #        responsibility for its operation is 100% yours.  However, what you are
  21. #        not permitted to do is to redistribute the source as "DSC Sample Code"
  22. #        after having made changes. If you're going to re-distribute the source,
  23. #        we require that you make it clear in the source that the code was
  24. #        descended from Apple Sample Code, but that you've made changes.
  25. #
  26. *************************************************************************************/
  27.  
  28.  
  29. #include <ToolUtils.h>
  30.  
  31. #include "App.h"
  32. #include "Global.h"
  33. #include "Proto.h"
  34.  
  35. #include "NetStuff.h"
  36.  
  37. #include <stdio.h>
  38. #include <sioux.h>
  39. //----------------------------------------------------------------------
  40. //
  41. //    main - main entry point of our program
  42. //
  43. //
  44. //----------------------------------------------------------------------
  45.  
  46. void main(void)
  47. {
  48.     OSErr            err;
  49.     long            total, contig;
  50.     short            m = 5;
  51.         
  52.     SIOUXSettings.autocloseonquit = true;
  53.     SIOUXSettings.asktosaveonclose = true;
  54.     SIOUXSettings.initializeTB = false;
  55.     SIOUXSettings.setupmenus = false;
  56.     SIOUXSettings.standalone = false;
  57.  
  58.     MaxApplZone();
  59.     
  60.     for (;m == 0;m--)                 // alloc the master pointers
  61.     {
  62.         MoreMasters();
  63.     }
  64.         
  65.     err = Initialize();
  66.  
  67.     EventLoop();
  68.  
  69.     ShutdownNetworking();
  70.     
  71.     AERemove();    
  72.     ExitToShell();
  73.  
  74. }
  75.  
  76.  
  77. //----------------------------------------------------------------------
  78. //
  79. //    HandleError - basic error notification procedure
  80. //
  81. //
  82. //----------------------------------------------------------------------
  83.  
  84. void HandleError(short errNo,Boolean fatal)
  85. {
  86.     DialogPtr            errDialog;
  87.     short                itemHit;
  88.     short                c;
  89.     Handle                button;
  90.     short                itemType;
  91.     Rect                itemRect;
  92.     StringHandle        errString;
  93.     Str255                numString;
  94.     GrafPtr                oldPort;
  95.     
  96.     GetPort(&oldPort);
  97.     SysBeep(30);
  98.     SetCursor(&qd.arrow);
  99.     
  100.     errDialog = GetNewDialog(rErrorDlg, nil, (WindowPtr) -1);
  101.     if (errDialog != nil) 
  102.     {
  103.         ShowWindow(errDialog);
  104.         SetPort(errDialog);
  105.         
  106.         PenPat(&qd.gray);                                // frame user areas
  107.         for (c = 7;c < 9;c++) 
  108.         {
  109.             GetDialogItem(errDialog,c,&itemType,&button,&itemRect);
  110.             FrameRect(&itemRect);
  111.         }
  112.         PenPat(normal);
  113.  
  114.         GetDialogItem( errDialog, fatal ? 2 : 1, &itemType, &button, &itemRect );
  115.         HiliteControl( (ControlHandle)button, 255);         //    unhilite appropriate button
  116.         
  117.         SetDialogDefaultItem(errDialog,fatal  ? 1 : 2);
  118.         
  119.         NumToString( errNo, numString );
  120.         if ( errNo < 0 )
  121.             errNo = -errNo + 200;
  122.         errString = GetString( 128 + errNo );
  123.         if ( errString == nil )
  124.                 errString = GetString( 128 );
  125.         HLock((Handle)errString);
  126.         
  127.         ParamText( numString, *errString, nil, nil );
  128.     
  129.         HUnlock((Handle)errString);
  130.         
  131.         ModalDialog( nil, &itemHit );
  132.         
  133.         SetPort( oldPort );
  134.  
  135.         DisposeWindow( errDialog );
  136.     }
  137.     else
  138.         ExitToShell();        // since didn't have mem to open dialog assume the worst
  139.             
  140.     if (fatal) 
  141.         ExitToShell();        //    it's a bad one, get out of here
  142.     
  143. }
  144.  
  145.  
  146. //----------------------------------------------------------------------
  147. //
  148. //    HandleAlert - display alert and then exit to shell
  149. //
  150. //
  151. //----------------------------------------------------------------------
  152.  
  153. void HandleAlert(short alertID)
  154. {
  155.     short            item;
  156.     
  157.     
  158.     item = Alert(alertID,nil);
  159.     ExitToShell();
  160.  
  161. }